﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Hongapo_Common;

public partial class sysadmin_Mall_malltypelist : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindRepetear();
        }
    }
    protected void btnUpdateAll_Click(object sender, EventArgs e)
    {
        updateAll();
    }

    protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName.Equals("del"))
        {
            int id = TypeConvert.ToInt32(e.CommandArgument);
            new Hongapo_Services.Mall.MallType().Delete(id);
            this.Show("删除成功！", "malltypelist.aspx");
        }
    }

    private void BindRepetear()
    {
        this.rptList.DataSource = new Hongapo_Services.Mall.MallType().GetList(" 1=1 order by sort");
        this.rptList.DataBind();
    }

    private void updateAll()
    {
        Hongapo_Model.Mall.MallType model = new Hongapo_Model.Mall.MallType();
        Hongapo_Services.Mall.MallType bll = new Hongapo_Services.Mall.MallType();
        for (int i = 0; i < this.rptList.Items.Count; i++)
        {
            int id = TypeConvert.ToInt32((this.rptList.Items[i].FindControl("lblID") as Label).Text);
            string type = (this.rptList.Items[i].FindControl("txtName") as TextBox).Text;
            string remark = (this.rptList.Items[i].FindControl("txtRemark") as TextBox).Text;
            int sort = TypeConvert.ToInt32((this.rptList.Items[i].FindControl("txtSort") as TextBox).Text);
            model.ID = id;
            model.Name = type;
            model.Remark = remark;
            model.Sort = sort;
            bll.Update(model);
        }
        this.Show("批量更新成功！", "malltypelist.aspx");
    }
}
